package com.wingsboat.file.config;

import com.wingsboat.common.core.enums.FileServerTypeEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author wangzhong
 * @description: 文件服务选择器
 * @date 2024/5/24 13:46
 */
@Component
public class FileServerSelector {

    /*
     * 用于动态加载local fastDfs minio的环境变量
     * */
    public static String selectorFileServerKey = "fileServer.selector";

    @Value("${fileServer.selector:local}")
    private String fileServerSelector;

    public String getFileServerSelector() {
        return fileServerSelector;
    }

    public void setFileServerSelector(String fileServerSelector) {
        fileServerSelector = fileServerSelector;
    }

    /**
     * 是否是本地服务
     * @return
     */
    public boolean isLocalFileServer(){
        return FileServerTypeEnum.LOCAL.getCode().equals(fileServerSelector);
    }

    /**
     * 是否是fastDfs服务
     * @return
     */
    public boolean isFastDfsServer(){
        return FileServerTypeEnum.FAST_DFS.getCode().equals(fileServerSelector);
    }

    /**
     * 是否是minio服务
     * @return
     */
    public boolean isMinioServer(){
        return FileServerTypeEnum.MINIO.getCode().equals(fileServerSelector);
    }
}
